package com.addcn.android.design591.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.addcn.android.design591.R;
import com.addcn.android.design591.comm.PermissionUtils;
import com.addcn.android.design591.utils.L;
import com.gjiazhe.panoramaimageview.GyroscopeObserver;
import com.gjiazhe.panoramaimageview.PanoramaImageView;

/**
 * Created by xuge on 2017/1/3.
 * 详情页测试
 */

public class TestDetailActivity extends AppCompatActivity {
    private Context context = this;
    private PanoramaImageView home_img;
    private GyroscopeObserver gyroscopeObserver;


    public static void launch(AppCompatActivity activity, View transitionView, int resId) {
        Intent intent = new Intent(activity, TestDetailActivity.class);
        intent.putExtra("resId", resId);
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
                transitionView, "home_img");
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.testdetail);
        initView();
    }

    private void initView() {
        home_img = (PanoramaImageView) findViewById(R.id.home_item_image_jyf);
        home_img.setImageResource(getIntent().getIntExtra("resId", R.mipmap.banner));
        ViewCompat.setTransitionName(home_img, "home_img");

        gyroscopeObserver = new GyroscopeObserver();
        home_img.setGyroscopeObserver(gyroscopeObserver);


        PermissionUtils.externalStorage(context, new PermissionUtils.PermissionCallBack() {
            @Override
            public void setOnPermissionListener(Boolean bo) {

            }
        });

        L.v("i am first");
        L.d("i am first");
        L.i("i am first");
        L.w("i am first");
        L.e("i am first");

    }

    @Override
    protected void onResume() {
        super.onResume();
        gyroscopeObserver.register(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        gyroscopeObserver.unregister();
    }
}
